package com.shen.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //如何让线程启动 Callable

        FutureTask futureTask = new FutureTask(new myThread());
        new Thread(futureTask).start();
        //call()

        //获取call()方法的返回值
        System.out.println(futureTask.get());
        //222
    }
}

class myThread implements Callable<String> {

    @Override
    public String call() {
        System.out.println("call()");
        return "222";
    }
}
